package baseTest;

public class RemoveDuplicates {
    public static void main(String[] args) {
        int[] arr = {2,2,3,4,4,5,7};
        System.out.println(process(arr));
    }
    public static int process(int[] nums){
        int p1 = 0;
        int p2 = 1;
        int end = nums.length-1;
        while (p1 != end){
            if (nums[p1] == nums[p2]){
                while (p2 < end){
                    swap(nums,p2,p2+1);
                    p2++;
                }
                p2 = p1+1;
                end--;
            }else {
                p1++;
                p2++;
            }

        }
        return end+1;
    }
    public static void swap(int[] arr,int a,int b){
        int step = arr[a];
          arr[a] = arr[b];
          arr[b] = step;
    }

}
